package com.tql.mall.boss.controller.boss;


import com.tql.mall.boss.service.BaseCategoryTrademarkService;
import com.tql.mall.common.result.R;
import com.tql.mall.model.product.BaseTrademark;
import com.tql.mall.model.product.CategoryTrademarkVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/boss/boss/baseCategoryTrademark")
public class BaseCategoryTradeMarkController {

    @Autowired
    private BaseCategoryTrademarkService baseCategoryTrademarkService;



    /**
     * admin/product/baseCategoryTrademark/save
     * 保存分类和品牌关联
     * @param categoryTrademarkVo
     * @return
     */
    @PostMapping("/save")
    public R<Void> save(@RequestBody CategoryTrademarkVo categoryTrademarkVo){



        baseCategoryTrademarkService.save(categoryTrademarkVo);

        return R.ok();
    }

    /**
     * admin/product/baseCategoryTrademark/findCurrentTrademarkList/{category3Id}
     *根据category3Id获取可选品牌列表
     * @param category3Id
     * @return
     */
    @GetMapping("/findCurrentTrademarkList/{category3Id}")
    public R<List<BaseTrademark>> findCurrentTrademarkList(@PathVariable Long category3Id){

        List<BaseTrademark> baseTrademarkList=baseCategoryTrademarkService.findCurrentTrademarkList(category3Id);


        return R.ok(baseTrademarkList);


    }



    /**
     * admin/product/baseCategoryTrademark/findTrademarkList/{category3Id}
     * 根据category3Id获取品牌列表
     * @param category3Id
     * @return
     */
    @GetMapping("/findTrademarkList/{category3Id}")
    public R<List<BaseTrademark>> findTrademarkList(@PathVariable Long category3Id){

       List<BaseTrademark> baseTrademarkList= baseCategoryTrademarkService.findTrademarkList(category3Id);


        return R.ok(baseTrademarkList);

    }

    /**
     * admin/product/baseCategoryTrademark/remove/{category3Id}/{trademarkId}
     * 删除分类品牌关联
     * @param category3Id
     * @param trademarkId
     * @return
     */
    @DeleteMapping("/remove/{category3Id}/{trademarkId}")
    public R<Void> remove(@PathVariable Long category3Id,
                         @PathVariable Long trademarkId ){

        baseCategoryTrademarkService.remove(category3Id,trademarkId);

        return R.ok();

    }


}
